/**
 * 初始化电子病历详情对话框
 */
var CdcEmrInfoDlg = {
    validateFields: {
    	episodeId: {
            validators: {
                notEmpty: {
                    message: '就诊记录不能为空'
                }
            }
        },
    	xcode: {
            validators: {
                notEmpty: {
                    message: '索引码不能为空'
                }
            }
        },
    	busEmrTypeId: {
            validators: {
                notEmpty: {
                    message: '文档类型不能为空'
                }
            }
        },
    	title: {
            validators: {
                notEmpty: {
                    message: '标题不能为空'
                }
            }
        },
    	subTitle: {
            validators: {
                notEmpty: {
                    message: '子标题不能为空'
                }
            }
        },
    	content: {
            validators: {
                notEmpty: {
                    message: '内容不能为空'
                }
            }
        },
    	emrDate: {
            validators: {
                notEmpty: {
                    message: '填写日期不能为空'
                }
            }
        },
    	emrUserId: {
            validators: {
                notEmpty: {
                    message: '填写人不能为空'
                }
            }
        },
    	dataId: {
            validators: {
                notEmpty: {
                    message: '业务数据类型不能为空'
                }
            }
        },
    	isActive: {
            validators: {
                notEmpty: {
                    message: '是否有效不能为空'
                }
            }
        },
    }
};


/**
 * 关闭此对话框
 */
CdcEmrInfoDlg.close = function() {
    parent.layer.close(parent.layer.getFrameIndex(window.name)); //先得到当前iframe层的索引,再执行关闭   
}

/**
 * 验证数据是否为空
 */
CdcEmrInfoDlg.validate = function () {
    $('#cdcEmrInfoForm').data("bootstrapValidator").resetForm();
    $('#cdcEmrInfoForm').bootstrapValidator('validate');
    return $("#cdcEmrInfoForm").data('bootstrapValidator').isValid();
}

/**
 * 提交新增
 */
CdcEmrInfoDlg.addSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('cdcEmrInfoForm',Sys.backendPath + "/cdc/cdcemr/add",function(res) {
        Sys.success(res.message);
    	window.parent.CdcEmr.table.refresh();
        CdcEmrInfoDlg.close();
    });
}

/**
 * 提交修改
 */
CdcEmrInfoDlg.editSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('cdcEmrInfoForm',Sys.backendPath + "/cdc/cdcemr/update",function(res) {
        Sys.success(res.message);
    	window.parent.CdcEmr.table.refresh();
        CdcEmrInfoDlg.close();
    });
}

$(function() {
	Sys.initValidator("cdcEmrInfoForm", CdcEmrInfoDlg.validateFields);
});
